package com.action;

import java.util.Map;

import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionSupport;

public class Buyitnow extends ActionSupport
{
	private Integer checklogin;
	private String submit;
	
	public String execute()throws Exception
	{
		
		if(submit.startsWith("BUY IT NOW"))
			checklogin=1;
		else if(submit.startsWith("ADD TO CART"))
			checklogin=2;
		else
			checklogin=3;
	
		Map session;
		session=ActionContext.getContext().getSession();
		session.put("checklogin",checklogin);
		String ebayuserid=(String)session.get("ebayuserid");
		System.out.println("The ebayuserid is"+ebayuserid);
		
		
		if(ebayuserid==null)     // To check if the user has logged in or not
		{
			return "signin";
		}
	
		
		else
		{
		
		if(submit.startsWith("BUY IT NOW"))
			return "orderconfirmation_buyitnow";
		else if(submit.startsWith("ADD TO CART"))
			return "addtocart";
		else
			return "confirmbid";
		
		}
		
		
	}

	public String getSubmit() {
		return submit;
	}

	public void setSubmit(String submit) {
		this.submit = submit;
	}

}
